<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:include="common/head::head('提现配置')"></head>

<body class="gray-bg">
<link href="../../resource/css/plugins/summernote/summernote.css" rel="stylesheet">
<link href="../../resource/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
<link href="../../resource/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet" />
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <fieldset>
                <form id="editForm" class="form-horizontal">
                    <fieldset>
                            <div class="well">
                                <div class="row">
                                    <label class="col-sm-2 control-label">余额提现配置：</label>
                                    <div class="col-sm-8">
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">起提金额：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="balanceMinAmount" id="balanceMinAmount" type="text"
                                                       th:value="${withdrawConfig.getBalanceMinAmount()}">
                                                <span class="input-group-addon">元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">上限金额：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="balanceMaxAmount" id="balanceMaxAmount" type="text"
                                                       th:value="${withdrawConfig.getBalanceMaxAmount()}">
                                                    <span class="input-group-addon">元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline" style="display: none;">
                                            <label class="col-sm-2 control-label">提现次数/月：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="balanceWithdrawNum" id="balanceWithdrawNum" type="text"
                                                       th:value="${withdrawConfig.getBalanceWithdrawNum()}">
                                                    <span class="input-group-addon">次</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">提现手续费：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="balanceWithdrawRatio" id="balanceWithdrawRatio" type="text"
                                                       th:value="${withdrawConfig.getBalanceWithdrawRatio()}">
                                                    <span class="input-group-addon">%</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="well well-lg">
                                <div class="row">
                                    <label class="col-sm-2 control-label">货款提现配置：</label>
                                    <div class="col-sm-8">
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">起提金额：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="goodsMinAmount" id="goodsMinAmount" type="text"
                                                       th:value="${withdrawConfig.getGoodsMinAmount()}">
                                                    <span class="input-group-addon">元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">上限金额：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="goodsMaxAmount" id="goodsMaxAmount" type="text"
                                                       th:value="${withdrawConfig.getGoodsMaxAmount()}">
                                                    <span class="input-group-addon">元</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline" style="display: none;">
                                            <label class="col-sm-2 control-label">提现次数/月：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="goodsWithdrawNum" id="goodsWithdrawNum" type="text"
                                                       th:value="${withdrawConfig.getGoodsWithdrawNum()}">
                                                    <span class="input-group-addon">次</span>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group form-inline">
                                            <label class="col-sm-2 control-label">提现手续费：</label>
                                            <div class="col-sm-4">
                                                <div class="input-group">
                                                <input class="form-control input-sm input-s-sm only-float" name="goodsWithdrawRatio" id="goodsWithdrawRatio" type="text"
                                                       th:value="${withdrawConfig.getGoodsWithdrawRatio()}">
                                                    <span class="input-group-addon">%</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <div class="col-sm-offset-5">
                            <button id="btnSubmitData" type="submit" class="btn btn-primary">保存</button>
                        </div>
                    </fieldset>
                </form>
            </fieldset>
        </div>
    </div>

</div>

<footer th:include="common/footer::js"/>
<script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js"></script>
<script src="/resource/lib/jquery-chain-select/jquery.chainSelect.js"></script>
<script src="/resource/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="/resource/lib/jquery-validation/dist/messages_cn.js"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js}"
></script>

<script src="../../resource/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
<script src="../../resource/js/plugins/summernote/summernote.min.js"></script>
<script src="../../resource/js/plugins/summernote/summernote-zh-CN.js"></script>
</body>
<script type="text/javascript">
    $(function () {
        pageHandler.init();
    });

    var pageHandler = {
        init: function () {
            $("#editForm").submit(function () {
                pageHandler.ajaxSubmit();
                return false;
            });
        },
        ajaxSubmit: function () {
            layer.load();
            $.ajax("/withdraw/saveWithdrawConfig", {
                method: 'POST',
                data: {
                    balanceMinAmount:$("#balanceMinAmount").val(),
                    balanceMaxAmount:$("#balanceMaxAmount").val(),
                    balanceWithdrawNum:$("#balanceWithdrawNum").val(),
                    balanceWithdrawRatio:$("#balanceWithdrawRatio").val(),
                    goodsMinAmount:$("#goodsMinAmount").val(),
                    goodsMaxAmount:$("#goodsMaxAmount").val(),
                    goodsWithdrawNum:$("#goodsWithdrawNum").val(),
                    goodsWithdrawRatio:$("#goodsWithdrawRatio").val()
        },
                success: function (apiResult) {
                    if (apiResult.resultCode === 2000) {
                        layer.close();
                        layer.msg("保存成功");

                            window.location.href='/withdraw/config';
                    } else {
                        hot.tip.error("操作失败--" + apiResult.resultMsg);
                    }
                }
            });


            // var self = this;
            // $("#editForm").ajaxSubmit({
            //     resetForm: false,
            //     beforeSubmit: function (formData, jqForm, options) {
            //         if (!$("#editForm").valid()) return false;
            //         layer.load();
            //         self.setButtonDisabled(true);
            //     },
            //     type: "post",
            //     dataType: "json",
            //     success: function (rep) {
            //         if (rep.success) {
            //             layer.close();
            //             layer.msg("保存成功");
            //             setTimeout(function () {
            //                 window.location.href.reload();
            //             }, 888);
            //         }
            //         else {
            //             layer.alert(rep.msg, {icon: 5});
            //             self.setButtonDisabled(false);
            //         }
            //     },
            //     error: function () {
            //         layer.alert("网络错误，请稍候再试。", {icon: 5});
            //         self.setButtonDisabled(false);
            //     }
            // });
        }
    };
</script>
</html>